<template>
  <div style="text-align:center">
    <x-header :title="title"></x-header>
    <divider v-show="isShow">{{loadingErr}}</divider>
    <x-img :src="src" :webp-src="`${src}?type=webp`" class="ximg" :offset="-100" container="#vux_view_box_body"></x-img>
  </div>
</template>
<script>
import { XHeader, XImg, Divider } from "vux";
export default {
  components: { XHeader, XImg, Divider },
  data() {
    return {
      title: "科目介绍",
      src: "",
      loadingErr: "页面走丢了"
    };
  },
  computed: {
    isShow() {
      return !this.src ;
    }
  },
  created: function() {
    const vm = this;
    vm.getInfo();
    vm.$bridge.registerhandler("jsCloseWebPage", (data, responseCallback) => {
      history.back();
      responseCallback("0");
    });
  },
  methods: {
    getInfo: function() {
      const vm = this;
      this.$api
        .getInfo(1)
        .then(response => {
          (vm.title = response.title), (vm.src = response.url);
        })
        .catch(err => {
          console.log("出错了" + err);
        });
    },
  }
};
</script>
<style scoped>
.ximg {
  width: 100%;
  height: auto;
}
</style>